#include <map>
#include <string>
#include <iostream>
using namespace std;

class CPhoneBook
{
private:
    map<string,string> pb;
public:
    CPhoneBook() {}
    ~CPhoneBook() {}

    void addItem(string name, string number)
    {
        pb[name] = number;
    }

    void delItem(string name)
    {
        pb.erase(name);
    }

    int size()
    {
        return pb.size();
    }

    string searchByName(string name)
    {
        map<string,string>::iterator it = pb.find(name);
        if(it!=pb.end())
            return it->second;
        else
            return "";
    }

    string searchByNumber(string number)
    {
        map<string,string>::iterator it = pb.begin();
        string name="";
        while(it!=pb.end())
        {
            if(it->second == number)
            {
                name = it->first;
                break;
            }
            it++;
        }
        return name;
    }

    friend istream &operator>>(istream &in, CPhoneBook &cpb)
    {
        string name, number;
        in >> name;
        while (name!="exit")
        {
            in >> number;
            cpb.pb[name] = number;
            in >> name;
        }
        return in;
    }

    friend ostream &operator<<(ostream& out, const CPhoneBook &cpb)
    {
        for(auto it = cpb.pb.begin(); it != cpb.pb.end(); it++)
            out<<it->first<<","<<it->second<<endl;
        return out;
    }
};

int main()
{
	CPhoneBook pb;

	cin >> pb;
	cout << pb;
	pb.addItem("LBJ","12-09-887-65");
	cout << pb;

	cout<<pb.searchByName("LBJ")<<endl;
	cout<<pb.searchByNumber("12-09-887-65")<<endl;
	cout<<pb.size()<<endl;
	pb.delItem("LBJ");
	cout << pb;

    return 0;
}
